package com.kn.musicmanagement.controller;

import com.kn.musicmanagement.pojo.Singer;
import com.kn.musicmanagement.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.mail.MessagingException;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/singer")
public class singerController {
    @Autowired
    private SingerService singerService;


    @GetMapping("/getAllSinger")
    public Result getAllSinger() {
        Result result = new Result();
        List<Singer> singers = singerService.getAllSinger();
        result.setCode(200);
        result.setData(singers);
        return result;
    }

    @GetMapping("/getSingerNum")
    public Result getSingerNum() {
        Result result = new Result();
        List<Singer> singers = singerService.getAllSinger();
        result.setCode(200);
        result.setData(singers.toArray().length);
        return result;
    }

    @GetMapping("/getUnapprovedSinger")
    public Result getUnapprovedSinger() {
        return singerService.getUnapprovedSinger();
    }

    @GetMapping("/getSingerME")
    public Result getSingerME(String singer_ID) {
        return singerService.getSingerDe(singer_ID);
    }


    @GetMapping("/ApprovedSinger")
    public Result ApprovedSinger(@RequestParam String singer_ID, @RequestParam String singer_Name) throws MessagingException {
        return singerService.ApprovedSinger(singer_ID, singer_Name);
    }

    @GetMapping("/ANoExamineSinger")
    public Result NoExamineSinger(@RequestParam String singer_ID, @RequestParam String singer_Name,
                                  @RequestParam String examination) throws MessagingException {
        return singerService.NoExamineSinger(singer_ID, singer_Name, examination);
    }

}
